<!-- TrainStudentStudyIndex.html -->
<!doctype html>
<html>
	<head>
		<meta charset="UTF-8">
		<meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
		<meta name="format-detection" content="telephone=no, email=no, date=no, address=no">
		<title>老师端——底部导航</title>
		<link rel="stylesheet" type="text/css" href="./css/api.css"/>
		<link rel="stylesheet" type="text/css" href="./css/style.css"/>
		<style>
			body {
				background-color: #fff;
			}
			#footer {
				background-color: #fff;
				height: 52px;
				overflow: hidden;
			}
			#footer ul li {
				padding-top: 32px;
				padding-bottom: 4px;
				background: url() no-repeat center 4px;
				background-size: auto 24px;
				text-align: center;
				color: #979797;
				font-size: 12px;
			}
			#footer ul li.active {
				color: #18b4ed;
			}
			#footer ul li:nth-child(1) {
				background-image: url(./icon/icon_kecheng1.png);
			}
			#footer ul li:nth-child(2) {
				background-image: url(./icon/icon_ketang.png);
			}
			/* #footer ul li:nth-child(3) {
			 background-image: url(./icon/icon_wode_normal.png);
			 } */
			#footer ul li:nth-child(1).active {
				background-image: url(./icon/icon_kecheng2.png);
			}
			#footer ul li:nth-child(2).active {
				background-image: url(./icon/icon_ketang1.png);
			}
			/* #footer ul li:nth-child(3).active {
			 background-image: url(./icon/icon_wode_selected.png);
			 } */
		</style>
	</head>
	<body>
		<!-- <div id="white_div"></div> -->
		<div id="wrap" class="flex-wrap flex-vertical">
			<div id="main" class="flex-con"></div>
			<div id="footer" class="border-t">
				<ul class="flex-wrap" >
					<li tapmode="hover" onclick="randomSwitchBtn( this, 0 );" class="flex-con active" >
						课程
					</li>
					<li tapmode="hover" onclick="randomSwitchBtn( this, 1 );" class="flex-con " >
						课堂
					</li>
					<!-- <li tapmode="hover" onclick="randomSwitchBtn( this, 2);" class="flex-con" >
					我的
					</li> -->
				</ul>
			</div>
		</div>
	</body>
	<script type="text/javascript" src="script/api.js"></script>
	<script type="text/javascript" src="script/requestTool.js"></script>
	<script type="text/javascript" src="script/databaseOperation.js"></script>
	<!-- <script type="text/javascript" src="script/TrainUploadLearningRecord.js"></script> -->
	<script type="text/javascript">
		DBReady = function() {
			//设置学习记录上传更新
			// setupUploadRecord();
			setupNotifi();
			setupGroup();
			ReceiveNotificationJump();
		}
		function setupNotifi() {
			api.addEventListener({
				name : 'offlineCloseWinNotifi'
			}, function(ret, err) {
				api.closeWin({
				});
			});
			//安卓下按2返回键退出
			api.addEventListener({
				name : 'keyback'
			}, function(ret, err) {
				api.closeWin({
				});
			});
		}

		function ReceiveNotificationJump() {
			var selectIndex = '';
			/*监听到首页中点了最新岗位 新闻中心更多按钮*/
			api.addEventListener({
				name : 'jumpStudy'
			}, function(ret, err) {
				if (ret) {//api.pageParam.type,
					selectIndex = ret.value.page;
					$api.setStorage('tabbarSelectedIndex', selectIndex);
					var num = selectIndex;
					var eFootLis = $api.domAll('#footer li'), eHeaderLis = $api.domAll('header li'), index = selectIndex;
					for (var i = 0, len = eFootLis.length; i < len; i++) {
						if (i == selectIndex) {
						} else {
							$api.removeCls(eFootLis[i], 'active');
							$api.removeCls(eHeaderLis[i], 'active');
						}
					}
					$api.addCls(eFootLis[index], 'active');
					$api.addCls(eHeaderLis[index], 'active');
					//切换导航
					api.setFrameGroupIndex({
						name : 'group',
						index : selectIndex
					});
					//切换frame
					api.sendEvent({
						name : 'hideClassroomFrameNotifi'
					});
					api.sendEvent({
						name : 'showTeachCourseFrameGroupNotifi'
					});
//					api.sendEvent({
//						name : 'hideOfflineAlertNotifi'
//					});
				}
			});
			if (api.pageParam.jumptype == 1) {
				selectIndex = 0;
				$api.setStorage('tabbarSelectedIndex', selectIndex);
				var num = selectIndex;
				var eFootLis = $api.domAll('#footer li'), eHeaderLis = $api.domAll('header li'), index = selectIndex;
				for (var i = 0, len = eFootLis.length; i < len; i++) {
					if (i == selectIndex) {
					} else {
						$api.removeCls(eFootLis[i], 'active');
						$api.removeCls(eHeaderLis[i], 'active');
					}
				}
				$api.addCls(eFootLis[index], 'active');
				$api.addCls(eHeaderLis[index], 'active');
				//切换导航
				api.setFrameGroupIndex({
					name : 'group',
					index : selectIndex
				});
				//切换frame
				api.sendEvent({
					name : 'hideClassroomFrameNotifi'
				});
				api.sendEvent({
					name : 'showTeachCourseFrameGroupNotifi'
				});
//				api.sendEvent({
//					name : 'hideOfflineAlertNotifi'
//				});
			}
		}

		function setupGroup() {
			var eHeaderLis = $api.domAll('header li'), frames = [];
			//添加学习页
			frames.push({
				name : 'Teacher_StudyCourseListWindow',
				url : 'html/Teacher_Teach/Teacher_StudyCourseListWindow.html',
				bgColor : '#fff',
				bounces : false,
				vScrollBarEnabled : false
			});
			//课堂
			frames.push({
				name : 'Classrom_index',
				url : 'html/Teacher_Classroom/Classrom_index.html',
				bgColor : '#fff',
				bounces : false,
				vScrollBarEnabled : false
			});
			// frames.push({
			// 	name : 'Teacher_Classroom',
			// 	url : 'html/CourseManage/liveStreamListWindow.html',
			// 	bgColor : '#fff',
			// 	bounces : false,
			// 	vScrollBarEnabled : false
			// });
			//添加我的页
			// frames.push({
			// 	name : 'TrainMine',
			// 	url : 'html/Practice_Mine/TrainMine.html',
			// 	pageParam : {
			// 		Indextype : 'learn'
			// 	},
			// 	bgColor : '#fff',
			// 	bounces : false,
			// 	reload : true,
			// 	vScrollBarEnabled : false,
			// 	hScrollBarEnabled : false
			// });
			var bottomH = $api.byId('footer').offsetHeight;
			//52
			var y = 0;
			var h = api.winHeight - bottomH;
			api.openFrameGroup({
				name : 'group',
				background : '#fff',
				scrollEnabled : false,
				rect : {
					x : 0,
					y : y,
					w : api.winWidth,
					h : h
				},
				index : 0,
				frames : frames,
				preload : 0
			}, function(ret, err) {
			});
		}

		// 随意切换按钮
		function randomSwitchBtn(tag, num) {
			//设置tabbar选中下标
			$api.setStorage('tabbarSelectedIndex', num);
			var eFootLis = $api.domAll('#footer li'), eHeaderLis = $api.domAll('header li'), index = 0;
			for (var i = 0, len = eFootLis.length; i < len; i++) {
				if (tag == eFootLis[i]) {
					index = i;
				} else {
					$api.removeCls(eFootLis[i], 'active');
					$api.removeCls(eHeaderLis[i], 'active');
				}
			}
			$api.addCls(eFootLis[index], 'active');
			$api.addCls(eHeaderLis[index], 'active');
			api.setFrameGroupIndex({
				name : 'group',
				index : index
			});
			if (num == 0) {
				api.sendEvent({
					name : 'showTeachCourseFrameNotifi'
				});
			} else {
				api.sendEvent({
					name : 'hideTeachCourseFrameNotifi'
				});
			}
			if (num == 1) {
				api.sendEvent({
					name : 'showClassroomFrameNotifi'
				});
			} else {
				api.sendEvent({
					name : 'hideClassroomFrameNotifi'
				});
			}
			// if (num != 2) {
			// 	api.sendEvent({
			// 		name : 'hideOfflineAlertNotifi'
			// 	});
			// }
		}
	</script>
</html>